#include "A.h"

#define eps 0.0001
#define M 1000

class Fun1 : public Fun
{
public:
	double f(double x)
	{
		return sin(x/2)-1;
	}      
};

double test1()
{
	Fun1 f1;
	Secant s(f1, 0, PI/2, eps, eps, M);
	return s.solve();
}

class Fun2 : public Fun
{
public:
	double f(double x)
	{
		return exp(x)-tan(x);
	}      
};

double test2()
{
	Fun2 f2;
	Secant s(f2, 1, 1.4, eps, eps, M);
	return s.solve();
}

class Fun3 : public Fun
{
public:
	double f(double x)
	{
		return pow(x,3)-12*x*x+3*x+1;
	}      
};

double test3()
{
	Fun3 f3;
	Secant s(f3, 0, -0.5, eps, eps, M);
	return s.solve();
}

int main()
{
	printf("The solution of sin(x/2)-1 is %f\n",test1());
	printf("The solution of e^x-tanx is %f\n",test2());
	printf("The solution of x^3-12x^2+3x+1 is %f\n",test3());
}